<?php

namespace App\Containers\AppSection\Moderation\Actions;

use App\Containers\AppSection\Moderation\Tasks\GetAllModerationsTask;
use App\Ship\Parents\Actions\Action;
use App\Ship\Parents\Requests\Request;

class GetModeratorModerationsAction extends Action
{
    public function run(Request $request)
    {

        return app(GetAllModerationsTask::class)
            ->addRequestCriteria()
            ->addOrderByCriteria()
            ->whereCondition('target', $request->getInputByKey('from_target'), $request->getInputByKey('to_target'))
            ->filterByProjectDate($request->getInputByKey('from_project'), $request->getInputByKey('to_project'))
            ->daysOfReturned($request->getInputByKey('from_returned'), $request->getInputByKey('to_returned'))
            ->whereCondition('min', $request->getInputByKey('from_min'), $request->getInputByKey('to_min'))
            ->filterByDate($request->getInputByKey('from'), $request->getInputByKey('to'))
            ->withProjectStatus($request->getInputByKey('status'))
            ->withPledge($request->getInputByKey('pledge'))
            ->withType($request->getInputByKey('type'))
            ->withStage('moderator')
            ->active()
            ->run();
    }
}
